package Operation;

import Book.BookList;

import java.util.Scanner;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 石方旭
 * Date: 2022-04-13
 * Time: 12:30
 */
public class ReturnOperation implements IOperation{

    @Override
    public void work(BookList book) {
        System.out.println("归还书籍");
        System.out.println("请输入你要归还的书籍");
        Scanner scan = new Scanner(System.in);
        String name = scan.nextLine();
        int i =0;
        for(i =0;i< book.getUsedSize();++i) {
            if(book.getPos(i).bookName.equals(name)) {
                System.out.println("查找成功~~~~-》"+"书籍信息如下所示：");
                System.out.println(book.getPos(i));
                if(book.getPos(i).isBorrow) {
                    book.getPos(i).isBorrow=false;
                    System.out.println("书籍归还成功");
                }
                return;
            }
        }
        if(i==book.getUsedSize()) {
            System.out.println("没有找到你要归还书籍所有信息");
        }
    }
}
